
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类的继承</title>
</head>
<body>
    
    <script>
        // es6  类与类的继承
         // 1.定义基础类
         class Base {
            name = "jack";
            age ;
            constructor(name,age){
                this.name = name
                this.age = age;
            }
            getInfo(){
                console.log(this.name+" : "+this.age);
            }
         }


         // 2.定义子类
         class  Son extends Base{
            constructor(name,age){
                super(name,age) //super关键字 指向父类构造器
            }
         }

         console.log(typeof Base);//类的本质是function
         console.log(typeof Son);

         let obj = new Son("tom",22)
         console.log(obj);
         console.log(obj.getInfo());
         


         

    </script>
</body>
</html>